﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace testing_thing
{
    public class GameEntity : IdentifiableObject
    {
        public GameEntity(string[] ids, bool isContainer)
            : base(ids)
        {
            if (isContainer)
            {
                _inventory = new Inventory();
            }
        }

        private string _title;

        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }

        private string _description;


        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        public string LongDescription
        {
            get
            {
                if (HasInventory)
                {
                    return Description + " "  + Title + " you can see:\n\n" + Inventory.ItemList;
                }
                else
                {
                    return "You can't look inside a " + Title;
                }
            }
        }

        public virtual GameEntity LocateEntity(string id)
        {
            if (this.IdentifiedBy(id))
            {
                return this;
            }
            else if (this.HasInventory)
            {
                return this.Inventory.AccessItem(id); 
            }

            return null;

        }

        private Inventory _inventory;

        public Inventory Inventory
        {
            get { return _inventory; }
        }
        public bool HasInventory
        {
            get
            {
                return _inventory != null;
            }
        }


    }
}
